import { Body, Controller, Get, Param, Post, UseInterceptors } from '@nestjs/common';
import { NewsService } from './news.service';
import { ResInterceptor } from '../interceptor/res.interceptor';

@Controller('/news')
@UseInterceptors(ResInterceptor)
export class NewsController {
    constructor(private readonly newsService: NewsService) {
    }

    // 获取新闻门户列表网站和api，动态生成
    @Get('/portals')
    getPortalList() {
        return [
            { name: '腾讯', api: '/tencent' },
            { name: '百度', api: '/baidu' },
            { name: '网易', api: '/163' },
        ];
    }

    @Get('/baidu')
    async getBaiduNews() {
        const res = await this.newsService.getBaiduNews();
        return res;
    }

    @Get('/tencent')
    async getTencentNews() {
        const res = await this.newsService.getTencentNews();
        return res;
    }

    @Get('/163')
    async get163News() {
        const res = await this.newsService.getNews163();
        return res;
    }
}
